<!--
 * @Author: 雷宇航
 * @Date: 2021-07-17 13:37:01
 * @LastEditTime: 2021-08-02 15:06:57
 * @LastEditors: 雷宇航
 * @Description: 
 * @FilePath: \icm-vue\src\views\hifar\contract\modules\ContractBidProjectDetailList.vue
-->
<template>
  <div v-if="mainId">
    <!-- table区域-begin -->
    <div v-if="showChangeTable">
      <a-tabs defaultActiveKey="1">
        <a-tab-pane :tab="index ? index + '、投标预审' : '投标预审'" key="1">
          <a-table
            ref="table"
            size="middle"
            :scroll="{ x: true }"
            bordered
            rowKey="id"
            :columns="saleColumns"
            :pagination="false"
            :dataSource="dataSource"
            :loading="loading"
            class="j-table-force-nowrap"
          >
          </a-table>
        </a-tab-pane>
      </a-tabs>
    </div>
  </div>
</template>

<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { getAction } from '@api/manage'

export default {
  name: 'BusBusinessSaleActivityDetailList',
  mixins: [JeecgListMixin],
  props: {
    mainId: {
      type: String,
      default: '',
      required: false,
    },
    index: {
      type: Number,
    },
  },
  watch: {
    mainId: {
      immediate: true,
      handler(val) {
        if (!this.mainId) {
        } else {
          this.queryParam['id'] = val
          this.loadData()
        }
      },
    },
  },
  data() {
    return {
      description: '投标预审详情表格页面',
      disableMixinCreated: true,
      showChangeTable: false,
      // 表头
      saleColumns: [
        {
          title: '序号',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },
        {
          title: '投标项目名称',
          align: 'center',
          dataIndex: 'name',
        },
        {
          title: '商机名称',
          align: 'center',
          dataIndex: 'opportunityName',
        },
        {
          title: '客户名称',
          align: 'center',
          dataIndex: 'customerName',
        },
        {
          title: '商机编号',
          align: 'center',
          dataIndex: 'opportunityNum',
        },
        {
          title: '投标报价',
          align: 'center',
          dataIndex: 'bidQuote',
        },
        {
          title: '采购费A',
          align: 'center',
          dataIndex: 'purchasea',
        },
        {
          title: '采购费B',
          align: 'center',
          dataIndex: 'purchaseb',
        },
        {
          title: '税费',
          align: 'center',
          dataIndex: 'taxation',
        },
        {
          title: '中标服务费',
          align: 'center',
          dataIndex: 'bidServiceCharge',
        },
        {
          title: '投标费用',
          align: 'center',
          dataIndex: 'bidCost',
        },
        {
          title: '预计毛利',
          align: 'center',
          dataIndex: 'grossProfit',
        },
      ],
      url: {
        list: '/bid/bidProject/queryById',
      },
      dataSource: [],
    }
  },
  mounted() {},
  methods: {
    loadData() {
      var param = Object.assign({}, this.queryParam)
      param.id = this.mainId
      getAction(this.url.list, param).then((res) => {
        if (res.success) {
          this.showChangeTable = Object.keys(res.result).length > 0
          this.dataSource = []
          this.dataSource.push(res.result)
          this.dataSource.forEach((v) => {
            v.bidQuote = this.toFixedFn(v.bidQuote) || 0
            v.purchasea = this.toFixedFn(v.purchasea) || 0
            v.purchaseb = this.toFixedFn(v.purchaseb) || 0
            v.taxation = this.toFixedFn(v.taxation) || 0
            v.bidServiceCharge = this.toFixedFn(v.bidServiceCharge) || 0
            v.bidCost = this.toFixedFn(v.bidCost) || 0
            v.grossProfit = this.toFixedFn(v.grossProfit) || 0
          })
        }
      })
    },
    toFixedFn(data) {
      if (data) {
        let res = data.toFixed(2)
        return res
      }
    },
  },
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>
